<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
        .a,
        .b,
        .c,
        .d {
            border: 1px dashed #333;
            padding: 20px;
            margin: 5px 0;
        }
    </style>
</head>

<body>
    <div id="app">
        <button @click="a++">a++</button>
        <button @click="b++">b++</button>
        <comp-a :a="a" :b="b"></comp-a>
    </div>
</body>
<script>

    var CompC = {
        props: ["a", "b"],
        data() {
            return {

            }
        },
        template: `<div class="c">
                <div>我是组件C:{{a}}---{{b}}</div>
            </div>`
    }


    var CompB = {
        props: ["a", "b"],
        data() {
            return {

            }
        },
        template: `<div class="b">
                <div>我是组件B:{{a}}---{{b}}</div>
                <comp-c :a="a" :b="b"></comp-c>
            </div>`,
        components: {
            CompC
        }
    }

    var CompA = {
        props: ["a", "b"],
        data() {
            return {

            }
        },
        template: `<div class="a">
                <div>我是组件A: {{a}}---{{b}}</div>
                <comp-b :a="a" :b="b"></comp-b>
            </div>`,
        components: {
            CompB,
        }
    }




    var CompD = {
        data() {
            return {

            }
        },
        template: `<div class="d">
                <div>我是组件D</div>
            </div>`
    }


    // 根组件
    var app = new Vue({
        el: "#app",
        data: {
            a: 1,
            b: 2,
        },
        components: {
            CompA: CompA,
            CompB: CompB,
        }
    })








</script>

</html>